import React from 'react'
import { useState } from 'react'
import { useCallback } from 'react'

export default function App() {
    const [name, setname] = useState("")
    const handClick = useCallback(() => {
        //缓存函数, 当[]中的依赖值改变时才会重新创建函数,否则使用之前缓存的值,起到优化作用
        setname("lyz")
    }, [name])
    return (
        <div>
            <button onClick={() => handClick}>click</button>
        </div>
    )
}
